function setFocus() {
    if (document.forms.length > 0) {
        if (setFocus.arguments.length == 0)
            formNr = 0;
        else
            formNr = setFocus.arguments[0];
        if (setFocus.arguments.length == 2) {
            document.forms[formNr].elements[setFocus.arguments[1]].focus();
        }
        else {
            if (document.forms[formNr].elements.length > 0) {
                for (i = 0; i < document.forms[formNr].elements.length; i++) {
                    if ("text,password".indexOf(document.forms[formNr].elements[i].type) > -1) {
                        try {
                            document.forms[formNr].elements[i].focus();
                            break;
                        }
                        catch (e) {
                        }
                    }
                }
            }
        }
    }
}

function checkForm(form, lang) {
    var msg = "";
    var empty = "";
    var check = "";
    var email = "";
    if (form.elements.length > 0) {
        for (i = 0; i < form.elements.length; i++) {
            if ((form.elements[i].type == "text") &&
                    (form.elements[i].value.length == 0) &&
                    (form.elements[i].name.indexOf("x_") == 0)) {
                form.elements[i].focus();
                if (empty.length)
                    empty = empty + ', ';
                empty = empty + form.elements[i].name.substr(2, 99);
//				msg = msg + form.elements[i].name.substr(2, 99) + ' muss einen Wert haben!\n';
            } else if ((form.elements[i].type == "checkbox") &&
                    (form.elements[i].checked == 0) &&
                    (form.elements[i].name.indexOf("x_") == 0)) {
                form.elements[i].focus();
                if (check.length)
                    check = check + ', ';
                check = check + form.elements[i].name.substr(2, 99);
//				msg = msg + form.elements[i].name.substr(2, 99) + ' muss gew%E4hlt werden!\n';
            } else if ((form.elements[i].type == "text") &&
                    (form.elements[i].name.toLowerCase().indexOf("email") != -1) &&
                    (form.elements[i].value != "") &&
                    (form.elements[i].value.indexOf('@', 1) == -1 || form.elements[i].value.indexOf('.', 3) == -1)) {
                form.elements[i].focus();
                if (email.length)
                    email = email + ', ';
                email = email + form.elements[i].name.substr(2, 99);
//				msg = msg + 'Falsches Email-Format!\n';
            }
        }
    }

    msg = empty + check + email;
    if (msg.length == 0)
        return true;
    else {
        msg = "";
        if (lang == "f") {
            if (empty.length)
                msg = msg + "Compl%E9t%E9es les cases suivantes S.V.P.: " + empty + '\n';
            if (check.length)
                msg = msg + "Choisisez les cases suivantes S.V.P.: " + check + '\n';
            if (email.length)
                msg = msg + "L'adresse e-mail est invalide: " + email + '\n';
        } else {
            if (empty.length)
                msg = msg + "Bitte f%FCllen Sie folgende Felder aus: " + empty + '\n';
            if (check.length)
                msg = msg + "Bitte w%E4hlen Sie folgende Felder: " + check + '\n';
            if (email.length)
                msg = msg + "Die Email-Adresse ist falsch: " + email + '\n';
        }
        alert(unescape(msg));
        return false;
    }
}

function clearField(field) {
    if (field.defaultValue == field.value)
        field.value = "";
}

function emailcheck(form, field, value) {
    if (value != "" && (value.indexOf('@', 1) == -1 || value.indexOf('.', 3) == -1))
        return false;
    else
        return true;
}

function mailto(name, domain) {
    var text = "";
    if (mailto.arguments.length > 2)
        text = mailto.arguments[2]
    else
        text = name + '@' + domain;

    document.write('<a href=\"mailto:' + name + '@' + domain + '\">' + text + '</a>');
}

function printBody() {
    var body = window.open(document.URL + '&Mode=print', 'printBody', 'menubar=yes,resizable=yes,scrollbars=yes,screenX=10,screenY=10');
    body.print()
}

function resize(width, height) {
    window.resizeTo(width + 8, height - 20);
}

function popupImage(bildname) {
    var eigenschaften, sbreite, shoehe, fenster, b, h;

    //Prfung, welche API zustไndig ist.
    var ns6 = (!document.all && document.getElementById);
    var ie4 = (document.all);
    var ns4 = (document.layers);

    //Bildschirmabmessungen feststellen
    if (ns6 || ns4) {
        sbreite = innerWidth;
        shoehe = innerHeight;
    }
    else if (ie4) {
        if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
            //IE 6+ in 'standards compliant mode'
            sbreite = document.documentElement.clientWidth;
            shoehe = document.documentElement.clientHeight;
        }
        else {
            //IE 4 compatible
            sbreite = document.body.clientWidth;
            shoehe = document.body.clientHeight;
        }
    }

    //Fenstergr๖sse
    b = 300;
    h = 300;

    //Linke obere Ecke des Fensters
    //x = (sbreite-b)/2;
    //y = (shoehe-h)/2;
    // feste linke obere Ecke
    x = 10;
    y = 10;

    //Wird dem zu ๖ffnenden Fenster mitgegeben
    eigenschaften = "left=" + x + ",top=" + y + ",width=" + b + ",height=" + h + ",menubar=no,toolbar=no,status=no,location=no,directories=0";

    fenster = window.open("", "", eigenschaften);
    fenster.focus();
    fenster.document.open();
    with (fenster) {
        document.write('<html><head>');
        document.write('<title>Bild</title></head>');
        document.write('<scr' + 'ipt type="text/javascr' + 'ipt" language="JavaScr' + 'ipt">');
        document.write("function click() { window.close(); } ");  // Fenster beim klicken schliessen
        document.write("document.onmousedown=click ");
        document.write('</scr' + 'ipt>');
        document.write('<body onload="window.resizeBy(document.images[0].width-300,document.images[0].height-300); " ');
        document.write('marginwidth="0" marginheight="0" topmargin="0" leftmargin="0" >');
        document.write('<img src="' + bildname + '" />');
        document.write('</body></html>');
    }
    //Beim ersten ๖ffnen des Fensters funktioniert moveTo nicht, daher wieder auskommentiert!
    //fenster.moveTo((sbreite-fenster.document.images[0].width)/2,(shoehe-fenster.document.images[0].height)/2);
    fenster.document.close();

    return false;
}